feat(debug): add more metrics in ThreadDebugState#2282
feat(debug): add more metrics in ThreadDebugState#2282alexandre-daubois wants to merge 1 commit intophp:mainfrom
Conversation
3968c59 to
aae0bd5
Compare
|
Could we measure the performance cost of this? Maybe should this feature be put behind a flag? |
|
Did I just spend 10 hours attempting to figure out why my other branch segfaults on 8.2 debian images and it's not actually related to my branch in the end? Certainly seems like it... |
I'll do benchmarks soon and we'll be able to see from there! |
|
This is the impact, on already existing benchmark:
Also, 0 additional allocation is recorded on the hot path. The impact is negligible and the metrics newly exposed would really help better monitor how things are going while processing requests. |
Sounds reasonable to me. Out of curiosity, does anybody know of a per-route monitoring solution that exposes metrics like number of requests, php request duration, etc.? Much like Sentry, Datadog or Tideways, but without all the low-level insights? Or perhaps that's a good candidate for a go php extension to hook into the runtime, gather the data, hand it to Go and add it to the prometheus metrics? |
|
Not that I'm aware of, but an extension for this purpose could indeed be a good idea |
aae0bd5 to
0ebcc00
Compare
Time to implement something. I'll create a proof of concept (I think this may even be implemented entirely in Go) and perhaps we can merge it upstream later. |
|
@alexandre-daubois @henderkes 👋🏻 this PR/discussion really got my attention I got some questions: @alexandre-daubois iiuc, this PR may outputs more data behind the
@henderkes your last post 'pic looks very promising, it seems built on top of the metric of frankenphp/caddy and prometheus scrapping correct? having, as a frankenphp/caddy module, such "low level visibility/monitoring tool" would be very valuable 👍🏻 I am writing/thinking out loud here, and not being really aware of go, frankenphp etc, I may miss some part ^^ thx ! |
Yes
Nope, documentation should be done as well!
I don't think it should return HTML, I think it would be weird. FrankenPHP exports raw data, it's up to people to format them the way they want. Maybe with an external extension 🙂 |
No, it needs to be documented.
Definitely json. Json is expected by prometheus.
No, that's app-specific prometheus metrics that can be visualised by Grafana or any other tool of your choice.
I think you're missing Prometheus and Grafana :P |
|
thx I will try to document such endpoint 👍🏻 I definitly got the metric over prometheus (what I described above) anyhow, thanks both of you @alexandre-daubois @henderkes cheers ! |
|
I checked and actually, the whole thing isn't documented yet at all. I'd rather see this one merged and take care of the exhaustive documentation for the |
|
Maybe we could create a third-party Caddy module embedding https://github.com/prometheus/prometheus/blob/main/web/ui/README.md and proxying the Caddy Prometheus API? |
|
Yes, that's a good idea! |

I'm working on an observability tool and exposing those metrics would be useful. For each thread, it exposes the current URI being processed, the method, the request start date, the request count and the memory usage.